let request = require("request");
const qiniu = require('qiniu')

function qiniuToken() {
	let accessKey = 'CDG9Vjox9CuSdhvq417CT0w-LXnSfM7K2Q2lqsh2';
	let secretKey = 'WizhSinS7pQrjLwpATx5HtyZuX5cO00f43Vn12pN';
	let mac = new qiniu.auth.digest.Mac(accessKey, secretKey);
	let options = {
		scope: "fanxin-code-img",
		returnBody: '{"key":"$(key)","url":"https:\/\/media.codecore.cn\/$(key)"}'
	};
	let putPolicy = new qiniu.rs.PutPolicy(options);
	let token = putPolicy.uploadToken(mac);
	return {
		token
	}
}

module.exports = {
	qiniuToken
}
